package com.xayy.ds.controller;

import cn.kawins.base.result.ResultBody;
import com.xtck.ha.common.core.constant.HttpStatus;
import com.xtck.ha.common.core.utils.poi.ExcelUtil;
import com.xtck.ha.common.core.web.controller.BaseController;
import com.xtck.ha.common.core.web.domain.AjaxResult;
import com.xtck.ha.common.core.web.page.TableDataInfo;
import com.xayy.ds.model.DsHealthSituation;
import com.xayy.ds.service.DsHealthSituationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 模型列表 controller
 *
 * @ClassName: DsHealthSituationController
 * @Description: 外部访问接口
 * @author liuyuan
 * @date 2025-07-07
 */
@Api(tags = "单星健康态势表信息管理")
@RestController
@RequestMapping("/api/v1.0/healthSituation")
public class DsHealthSituationController extends BaseController {

    @Autowired
    private DsHealthSituationService dsHealthSituationService;


    @ApiOperation("分页查询单星健康态势表信息列表")
    @GetMapping("/page")
    public AjaxResult page(DsHealthSituation dsHealthSituation)
    {
        startPage();
        List<DsHealthSituation> list = dsHealthSituationService.selectTList(dsHealthSituation);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setList(list);
        rspData.setMsg("查询成功");
        rspData.setTotal(dsHealthSituationService.count(dsHealthSituation));
        return AjaxResult.success(rspData);
    }

    @ApiOperation("列表查询单星健康态势表信息")
    @GetMapping("/list")
    public List<DsHealthSituation> list(DsHealthSituation dsHealthSituation)
    {
        List<DsHealthSituation> list = dsHealthSituationService.selectTList(dsHealthSituation);
        return list;
    }

    @ApiOperation("导出单星健康态势表信息列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsHealthSituation dsHealthSituation)
    {
        List<DsHealthSituation> list = dsHealthSituationService.selectTList(dsHealthSituation);
        ExcelUtil<DsHealthSituation> util = new ExcelUtil<>(DsHealthSituation.class);
        util.exportExcel(response, list, "样例数据");
    }

    @ApiOperation("获取$单星健康态势表信息详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dsHealthSituationService.selectTById(id));
    }

    @ApiOperation("新增$单星健康态势表信息")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DsHealthSituation dsHealthSituation)
    {
        return toAjax(dsHealthSituationService.insertT(dsHealthSituation));
    }

    @ApiOperation("修改单星健康态势表信息")
    @PutMapping
    public AjaxResult update(@RequestBody DsHealthSituation dsHealthSituation)
    {
        int i = dsHealthSituationService.updateT(dsHealthSituation);
        return toAjax(i);
    }

    @ApiOperation("删除单星健康态势表信息")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dsHealthSituationService.deleteTByIds(ids));
    }

    @GetMapping("/getHealthDeepInfo/{nodeId}")
    @ApiOperation(value = "获取单星健康态势-右侧表单数据", httpMethod = "GET", notes = "获取单星健康态势-右侧表单数据")
    public ResultBody getHealthDeepInfo(@PathVariable Long nodeId) {
        return dsHealthSituationService.getHealthDeepInfo(nodeId).body();
    }





}
